#!/usr/bin/perl

if ($#ARGV != 1)
  { die "Wrong number of arguments\n"; }

# train
open (IN, $ARGV[0]) || die "Couldn't open input file.\n";

# read word on first line.
#$word = <IN>;
#chop $word;
# make regexp
#$reg = $word . "_(\\S+)";
$reg = "_(\\S+)";
$reg =~ tr/[|]/[.]/;
#print "$reg\n";
while (<IN>)
  {
  if ($_ =~ $reg)
    {
 #   print $1;
    $counts{$1} += 1;
    }
  }
close(IN);

  
$sense = 1;
$max = 0;
foreach $key (sort(keys %counts))
  {
#	print "Found $counts{$key} instances of $key\n";
  if ($counts{$key} > $max)
    {
    $max = $counts{$key};
    $sense = $key;
    }
  }

# do testing   
open (OUT, $ARGV[1]) || die "Couldn't open output file.\n";

while (<OUT>)
  {
  print "$sense\n";
  }
close(OUT);
